<template>
    <!-- 修改角色 -->
  <el-card style="max-width: 1000px;margin: 0 auto;height: 500px;">
   <table style="width: auto;margin: 0 auto;height: auto;">
        <thead>
            <tr>
                <td><span
                        style="color: black;padding:20px;font-size: 30px;font-weight: bold;">盘点单号:{{ tableData.inventoryAudit_Code }}</span>
                </td>
            </tr>
        </thead>
        <tr>
            <td>
                <span>制单人:{{tableData.inventory_Shoppings}}</span>
                <span style="padding-left: 30%;">所在部门:{{tableData.inventory_Quantity}}</span>
                <span style="padding-left: 30%;">制单时间:{{tableData.inventory_Starttime}}</span>
            </td>
        </tr>
        <tr>
            <td>
                <span>盘点类型:{{ tableData.inventory_Type }}</span>
                <span style="padding-left: 30%;">盘点开始时间:{{ tableData.inventory_Starttime }}</span>
                <span style="padding-left: 30%;">盘点结束时间:{{ tableData.inventory_Endtime }}</span>
            </td>
        </tr>
        <tr>
            <td>
                <span>仓库名称:{{ tableData.warehouse_Name }}</span>
                <span style="padding-left: 30%;">经办人:{{}}</span>
                <span style="padding-left: 30%;">备注:{{}}</span>
            </td>
        </tr>
    </table>
  </el-card>
 
  <el-card style="max-width: 1000px;margin: 0 auto;height: 500px;">
  <el-tabs v-model="activeName" @tab-click="handleTabClick">
    <el-tab-pane label="其他信息" name="OutLogging"></el-tab-pane>
    <el-tab-pane label="盘点明细" name="CenDsction"></el-tab-pane>
    <el-tab-pane label="入库记录" name="ProductOutAllowsView"></el-tab-pane>
    <el-tab-pane label="出库记录" name="InCentent"></el-tab-pane>
    <router-view />
  </el-tabs>
  </el-card>
</template>

<script lang="ts" setup>
import { onMounted, reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import axios from 'axios'
import { useRouter, useRoute } from 'vue-router'
import type { UploadProps, UploadUserFile } from 'element-plus'
import { Plus, Close } from '@element-plus/icons-vue'
const router = useRouter()//路由传递地址
const route = useRoute()
const activeName = ref(route.name || 'FarmingsAll')
// import { http } from '@/axios/axiosHelpers'
import { systeamread } from '@/systeamaxios/sysaxiosHelpers'
const AdddialogVisible = ref(false)
const UpdatedialogVisible = ref(false)
const Oppen2 = ref(false)
const LogExport = ref(false)
const addIds = ref<any>([])
const ExportCouts = reactive({
    cout: ""
})
//标签页触发事件的方法
const handleTabClick = (tab: any) => {
  router.push({
    path: `/${tab.paneName}`,
    query: {
      Batch: location.search.split("=")[1]
    } // 保持原有参数，比如id
  })
}
//表格加入
const Page = reactive({
    pageIndex: 1,
    pageSize: 15,
    total: 0,
    totalPage: 0
})
const bt = reactive({
    bid: 0
})
const tableData = reactive({
    "isDel": false,
    "inventoryAudit_Id": 0,
    "inventoryAudit_Code": "string",
    "inventory_Result": "",
    "warehouse_Name": "",
    "inventory_Type": "",
    "inventory_Starttime": "",
    "inventory_Endtime": "",
    "outbound_Status": true,
    "inbound_Status": true,
    "inventory_Shoppings": "",
    "inventory_Quantity": 0,
    "profitQuantity": 0
})

const AddOppen = () => {
    AdddialogVisible.value = true
}
const OppenExports = () => {
    LogExport.value = true
}


const Show = () => {
    systeamread.get("/api/InventoryAuditsAll/FistInventoryAudit", {
        params: {
            id: location.search.split("=")[1],
        }
    }).then(res => {
        tableData.inventoryAudit_Id = res.data.data.inventoryAudit_Id
        tableData.inventoryAudit_Code = res.data.data.inventoryAudit_Code
        tableData.inventory_Result = res.data.data.inventory_Result
        tableData.warehouse_Name = res.data.data.warehouse_Name
        tableData.inventory_Type = res.data.data.inventory_Type
        tableData.inventory_Starttime = res.data.data.inventory_Starttime
        tableData.inventory_Endtime = res.data.data.inventory_Endtime
        tableData.outbound_Status = res.data.data.outbound_Status
        tableData.inbound_Status = res.data.data.inbound_Status
        tableData.inventory_Shoppings = res.data.data.inventory_Shoppings
        tableData.inventory_Quantity = res.data.data.inventory_Quantity
    })

}
onMounted(() => {
    Show()
    GetChange()
})
const GetChange=()=>{
      if (route.path === '/InventoryAuditEdit') {
    router.replace({
      path: '/ProductOutAllowsView',
    //   query: {
    //     Batch: location.search.split("=")[1]
    //   }
    })
  }
  activeName.value = route.path.split('/').pop() || 'FarmingsAll'
}
const DeleteAll = () => {
    // http.get("/managementsysteamreadapis/api", {
    systeamread.get("/api/").then(res => {
        ElMessage.success(res.data.message)
    })
}
const Delete = (id: number) => {
    if (!confirm("确定删除吗"))
        return;
    // http.delete("/managementsysteamreadapis/api/ProductOutAllowAll/DelProductOutAllow", {
    systeamread.delete("/api/ProductOutAllowAll/DelProductOutAllow", {
        params: {
            ProductOutAllowtMent_Id: id
        }
    })
        .then(res => {
            ElMessage.success(res.data.message)
            Show()
        })
}
const Edit = (id: number) => {
    bt.bid = id
    Oppen2.value = true
}

const EditAll = () => {
    // 这里应该实现批量编辑的逻辑
    // 可以根据选中的 addIds 来处理
    if (addIds.value.length === 0) {
        ElMessage.warning('请先选择要编辑的项目')
        return
    }

    // 这里可以打开编辑对话框或执行其他编辑操作
    ElMessage.info('批量编辑功能待实现')
}

</script>